<template>
    <el-table-column class="table-date" :prop="prop" :label="labelComputed" align="center" min-width="80">
        <template slot-scope="scope">
            <span class="date" v-if="scope.row[prop]" v-text="scope.row[prop].split(' ')[0]"></span><br>
            <span class="time" v-if="scope.row[prop]" v-text="scope.row[prop].split(' ')[1]"></span>
        </template>
    </el-table-column>
</template>

<script type="text/ecmascript-6">
  /**
   * @author 白雨浓
   * @date 2018/12/7 14:16
   *
   * 列表中 的 时间 字段
   **/
  export default {
    name: 'ElTableDate',
    props: {
      prop: {
        type: String,
        required: true
      },
      label: {
        type: String,
      }
    },
    computed: {
      labelComputed() {
        if (this.label) {
          return this.label;
        }

        if (this.prop.toLowerCase().includes('create')) {
          return '创建时间';
        } else if (this.prop.toLowerCase().includes('update')) {
          return '更新时间';
        }
      },
    },
    methods: {}
  }
</script>

<style lang="stylus" rel="stylesheet/stylus" scoped>
    .table-date {
    }

    .date {
        font-size .8em
        line-height 5px
    }

    .time {
        font-size .8em
        line-height 5px
    }
</style>
